<?php

namespace Liuhelong\LaravelAdmin\Wechat\Console\Commands;

use Encore\Admin\Auth\Database\Menu;
use Illuminate\Console\Command;

class CreateMenu extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'wechat:createMenu';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '生成所需的菜单数据记录';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $menu = Menu::query()->firstOrCreate([
            'title' => '微信管理',
        ],[
            'parent_id' => 0,
            'order' => 80,
            'icon' => 'fa-wechat',
        ]);


        $materials = Menu::query()->firstOrCreate([
            'title' => '素材管理',
            'parent_id' => $menu->id,
        ],[
            'order' => 80,
            'icon' => 'fa-file-picture-o',
        ]);

        $functions = Menu::query()->firstOrCreate([
            'title' => '事件/消息',
            'parent_id' => $menu->id,
        ],[
            'order' => 80,
            'icon' => 'fa-adn',
        ]);
		
		
        //  素材
        Menu::query()->firstOrCreate([
            'title' => '图文消息（公众号）',
            'parent_id' => $materials->id,
        ],[
            'order' => 80,
            'icon' => 'fa-newspaper-o',
            'uri' => 'wechat/wechat-o-mp-news-article'
        ]);
        Menu::query()->firstOrCreate([
            'title' => '图片',
            'parent_id' => $materials->id,
        ],[
            'order' => 80,
            'icon' => 'fa-file-image-o',
            'uri' => 'wechat/wechat-o-materials?type=image'
        ]);
        Menu::query()->firstOrCreate([
            'title' => '音频',
            'parent_id' => $materials->id,
        ],[
            'order' => 80,
            'icon' => 'fa-file-audio-o',
            'uri' => 'wechat/wechat-o-materials?type=voice'
        ]);
        Menu::query()->firstOrCreate([
            'title' => '视频',
            'parent_id' => $materials->id,
        ],[
            'order' => 80,
            'icon' => 'fa-file-video-o',
            'uri' => 'wechat/wechat-o-materials?type=video'
        ]);
        Menu::query()->firstOrCreate([
            'title' => '图文消息（自定义）',
            'parent_id' => $materials->id,
        ],[
            'order' => 80,
            'icon' => 'fa-newspaper-o',
            'uri' => 'wechat/wechat-o-news'
        ]);
        Menu::query()->firstOrCreate([
            'title' => '客服消息',
            'parent_id' => $materials->id,
        ],[
            'order' => 80,
            'icon' => 'fa-comments-o',
            'uri' => 'wechat/wechat-o-cs-messages'
        ]);
        
        //  事件/消息
        Menu::query()->firstOrCreate([
            'title' => '消息',
            'parent_id' => $functions->id,
        ],[
            'order' => 80,
            'icon' => 'fa-comments',
            'uri' => 'wechat/wechat-o-message-functions'
        ]);
        Menu::query()->firstOrCreate([
            'title' => '事件',
            'parent_id' => $functions->id,
        ],[
            'order' => 80,
            'icon' => 'fa-hand-pointer-o',
            'uri' => 'wechat/wechat-o-event-functions'
        ]);

		
		
		Menu::query()->firstOrCreate([
            'title' => '公众号菜单',
            'parent_id' => $menu->id,
        ],[
            'order' => 80,
            'icon' => 'fa-bars',
            'uri' => 'wechat/wechat-o-menus'
        ]);

		Menu::query()->firstOrCreate([
            'title' => '二维码',
            'parent_id' => $menu->id,
        ],[
            'order' => 80,
            'icon' => 'fa-qrcode',
            'uri' => 'wechat/wechat-o-qrcodes'
        ]);
        Menu::query()->firstOrCreate([
            'title' => '客服',
            'parent_id' => $menu->id,
        ],[
            'order' => 80,
            'icon' => 'fa-headphones',
            'uri' => 'wechat/wechat-o-customer-serivces'
        ]);
        Menu::query()->firstOrCreate([
            'title' => '模板消息',
            'parent_id' => $menu->id,
        ],[
            'order' => 80,
            'icon' => 'fa-commenting-o',
            'uri' => 'wechat/wechat-o-template-messages'
        ]);
		Menu::query()->firstOrCreate([
            'title' => '事件日志',
            'parent_id' => $menu->id,
        ],[
            'order' => 80,
            'icon' => 'fa-database',
            'uri' => 'wechat/wechat-o-event-logs'
        ]);
        
        Menu::query()->firstOrCreate([
            'title' => '公众号群发',
            'parent_id' => $menu->id,
        ],[
            'order' => 80,
            'icon' => 'fa-bullhorn',
            'uri' => 'wechat/wechat-o-broadcasts'
        ]);
		/*Menu::query()->firstOrCreate([
            'title' => '用户',
            'parent_id' => $menu->id,
        ],[
            'order' => 80,
            'icon' => 'fa-users',
            'uri' => 'wechat/wechat-o-users'
        ]);*/
		
        $this->info('菜单生成完毕');
    }
}